<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>物资采购与产品整合管理系统</title>
<link href="${pageContext.request.contextPath }/css/main.css" rel="stylesheet" type="text/css" media="all" />
<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
	<script>
		$(function () {
			$("#billflag").change(function () {
				$.ajax({
					url:"${pageContext.request.contextPath}/retory.do?op=ajaxquery",
					type:"post",
					data:"billflag="+$("#billflag").val(),
					dataType:"json",
					success:function (result) {

						$("#billtype>option").remove(":not(:first)");
						for (var i=0;i<result.length;i++){
							$("#billtype").append("<option value="+result[i].code+">"+result[i].name+"</option>")
						}
					}
				})
			});
				$.ajax({
					url:"${pageContext.request.contextPath}/retory.do?op=queryid",
					type:"post",
					dataType:"json",
					success:function (result) {
						for (var i=0;i<result.length;i++){
							$("#partsid").append("<option value="+result[i].partsid+">"+result[i].partsname+"</option>")
						}
					}
				});
			$("#partsid").change(function () {
				$.ajax({
					url:"${pageContext.request.contextPath}/retory.do?op=querycount",
					type:"post",
					data:"partsid="+$("#partsid").val(),
					dataType:"text",
					success:function (result) {
                        $("#partsNum").val(result);
					}
				})
		});
			$("#btn_save").click(function () {
				//表单的jQuery对象有一个序列化方法，获得表单数据的请求参数字符串；
				$.ajax({
					url:"${pageContext.request.contextPath}/retory.do?op=save",
					type:"post",
					dataType:"json",
					data:$("#coursesCreat").serialize(),
					success:function (result) {
						$("#partsNum").val(result.data.partsreqcount);
						alert(result.msg);
					}
				})
			})


		})
	</script>

</head>

<body class="content-pages-body">
<div class="content-pages-wrap">
    <div class="commonTitle">
        <h2>&gt;&gt; 配件出入库</h2>
  </div>
        <form id="coursesCreat" name="coursesCreat" action="${pageContext.request.contextPath}/retory.do?op=save" method="post" >
		  <table border="0" cellspacing="1" cellpadding="0" height="70" class="commonTable">
			  <tr>
				<td width="10%" align="right" class="title"><span class="required">*</span>类型：</td>
				<td width="15%" align="left">
					<select style="width:150px;" id="billflag" name="billflag">
						<option value="0">---请选择---</option>
						<option value="in">入库</option>
						<option value="out">出库</option>
					</select>
				</td>
				<td width="10%" align="right" class="title"><span class="required">*</span>出/入库类型：</td>
				<td width="15%" align="left">
					<select style="width:150px;" id="billtype" name="billtype">
						<option value="0">---请选择---</option>

					</select>
				</td>
				<td width="10%" align="right" class="title"><span class="required">*</span>出/入库日期：</td>
				<td width="15%" align="left" name="billtime">
					<jsp:useBean id="now"  scope="page" class="java.util.Date"></jsp:useBean>
					<fmt:formatDate value="${now }" pattern="yyyy年MM月dd日"/>
				</td>
				<td width="10%" align="right" class="title"><span class="required">*</span>操作员：</td>
				<td width="15%" align="left"><input type="hidden" name="billuser" value=""></td>
			  </tr>
			  <tr>
				<td width="10%" align="right" class="title"><span class="required">*</span>配件：</td>
				<td width="15%" align="left">
					<select style="width:150px;" name="partsid" id="partsid">
						<option value="0">---请选择---</option>
					</select>
				</td>
				<td width="10%" align="right" class="title"><span class="required">*</span>出/入库数量：</td>
				<td width="15%" align="left">
					<input name="billcount" type="text" style="width:150px;height:20px">
				</td>
				<td width="10%" align="right" class="title"><span class="required"></span>现有库存数：</td>
				<td width="15%" align="left" colspan="3"><input readonly="readonly" type="text" id="partsNum" style="width:470px;height:20px" disabled>
				</td>
			  </tr>
		 </table>
		</form>
	 </div>
    <!--//commonTable-->
    <div id="formPageButton">
    	<ul>
			<li><a href="javascript:void(0)" title="保存" class="btnShort" id="btn_save">保存</a></li>
        	<li><a href="javascript:window.history.go(-1)" title="返回" class="btnShort">返回</a></li>
        </ul>
    </div>
    <!--//commonToolBar-->
</div>
<!--//content pages wrap-->
</body>
</html>
